package com.lh.controller;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.lh.base.ResResult;
import com.lh.pojo.SysUser;
import com.lh.pojo.User;
import com.lh.service.SysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author lh
 * @since 2021-03-02
 */
@RestController
@RequestMapping("/sys-user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserServiceImpl;

    @PostMapping("/login")
    @ApiOperation(value = "用户登录")
    @DynamicParameters(properties = {
            @DynamicParameter(name = "username", value = "用户名", required = true),
            @DynamicParameter(name = "password", value = "密码", required = true),
    })
    public ResResult login(@RequestBody JSONObject sysUser) {
        return sysUserServiceImpl.userLogin(BeanUtil.toBean(sysUser, SysUser.class));
    }

}

